package com.meetup.controller;

import org.hibernate.Session;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.stereotype.Controller;

import org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter;
import org.springframework.http.converter.BufferedImageHttpMessageConverter;
import org.springframework.http.converter.ByteArrayHttpMessageConverter;
import org.springframework.http.converter.StringHttpMessageConverter;

//import org.springframework.http.converter.ResourceHttpMessageConverter;
import org.springframework.http.converter.xml.SourceHttpMessageConverter;
import org.springframework.http.converter.xml.SourceHttpMessageConverter;
//import org.springframework.http.converter.xml.XmlAwareFormHttpMessageConverter;
import org.springframework.http.converter.xml.Jaxb2RootElementHttpMessageConverter;
//import org.springframework.http.converter.json.MappingJacksonHttpMessageConverter;
import com.meetup.utility.HibernateUtility;
import com.meetup.domain.Stock;

@Controller

public class StockController {
	
	@RequestMapping(value="/mapping/path", method = RequestMethod.GET,headers = "Accept=application/xml")
	public @ResponseBody Stock byPath() {
		System.out.println("stdout - Returning hello view");
	
	System.out.println("Maven + Hibernate + MySQL");
    Session session = HibernateUtility.getSessionFactory().openSession();
    
    session.beginTransaction();
    Stock stock = (Stock) session.get(Stock.class, 14);
    session.getTransaction().commit();
    return stock;
//    session.beginTransaction();
//    Stock stock = new Stock();
//    
//    stock.setStockCode("4715");
//    stock.setStockName("GENM");
//    
//    session.save(stock);
//    session.getTransaction().commit();
//    
//	return stock.getStockName();
	}
}